﻿using System;
using System.Collections.ObjectModel;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace G.APITest.Utils
{
    public static class ProjectTemplateTableUtils
    {

        private const string dbAddress = LocalStaticConfig.DBDirectoryName + "/ProjectTemplateTable.json";
        static ObservableCollection<Data.ProjectTemplate> ProjectTemplateTable;
        public static ObservableCollection<Data.ProjectTemplate> LoadTable()
        {
            if (ProjectTemplateTable == null)
            {
                ProjectTemplateTable = G.SL.Utils.APPFileHelp.DeserializeObjectFromFile<ObservableCollection<Data.ProjectTemplate>>(dbAddress, G.SL.Utils.FileContentType.JSON);
                if (ProjectTemplateTable == null)
                    ProjectTemplateTable = new ObservableCollection<Data.ProjectTemplate>();
            }
            return ProjectTemplateTable;
        }

        public static void SaveTable()
        {
            if (ProjectTemplateTable != null)
                G.SL.Utils.APPFileHelp.SerializeObjectToFile(dbAddress, ProjectTemplateTable, G.SL.Utils.FileContentType.JSON);
        }


    }
}
